"""
Case Type   : cm_ctl
Case Name   : 资源池化集群执行cm_ctl pause/resume参数异常，合理报错
Create At   : 2024/04/05
Owner       : @kyeleze
Description :
    1.执行cm_ctl pause参数异常
    2.执行cm_ctl resume参数异常
Expect      :
    1.合理报错
    2.合理报错
History     :
"""

import os
import unittest

from testcase.utils.CommonSH import CommonSH
from testcase.utils.Constant import Constant
from testcase.utils.Logger import Logger

primary_sh = CommonSH('PrimaryDbUser')


@unittest.skipIf(3 != primary_sh.get_node_num(), '非1+2环境不执行')
class CmPauseResumeCase(unittest.TestCase):
    def setUp(self):
        self.log = Logger()
        self.log.info(f'----{os.path.basename(__file__)} start----')
        self.constant = Constant()
        self.primary_sh = CommonSH('PrimaryDbUser')

    def test_cm(self):
        step = '--step1:执行cm_ctl pause参数异常 expect:合理报错--'
        self.log.info(step)
        result = self.primary_sh.exec_cm_ctl('pause', '-D')
        self.log.info(result)
        self.assertIn("option requires an argument -- 'D'", result,
                      "执行失败:" + step)

        step = '--step2:执行cm_ctl resume参数异常 expect:合理报错--'
        self.log.info(step)
        result = self.primary_sh.exec_cm_ctl('resume', '-D')
        self.log.info(result)
        self.assertIn("option requires an argument -- 'D'", result,
                      "执行失败:" + step)

    def tearDown(self):
        self.log.info(f'----{os.path.basename(__file__)} end----')
